<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{{ main-title }} -- AdminPanel</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            display: flex;
        }
        .sidebar {
            width: 250px;
            background-color: #333;
            color: white;
            height: 100vh;
            padding-top: 20px;
        }
        .sidebar a {
            padding: 10px 15px;
            text-decoration: none;
            color: white;
            display: block;
        }
        .sidebar a:hover {
            background-color: #575757;
        }
        .content {
            flex-grow: 1;
            padding: 20px;
        }
        .header {
            background-color: #f1f1f1;
            padding: 10px;
            border-bottom: 1px solid #ddd;
        }
        .main-content {
            margin-top: 20px;
        }
        .btn {
            display: inline-block;
            padding: 10px 20px;
            font-size: 16px;
            color: white;
            background-color: #007BFF;
            border: none;
            border-radius: 5px;
            text-decoration: none;
            cursor: pointer;
        }
        .btn:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
    <div class="sidebar">
        <a href="#article">文章</a>
        <a href="#styles">样式</a>
    </div>
    <div class="content">
        <div class="header">
            <h1>管理面板</h1>
        </div>
        <div class="main-content" id="main-content">
            <p>欢迎 {{ panel_username }} 使用博客后台管理面板</p>
        </div>
    </div>

    <script>
        document.querySelectorAll('.sidebar a').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                const target = this.getAttribute('href').substring(1);
                displayContent(target);
            });
        });

        function displayContent(target) {
            const mainContent = document.getElementById('main-content');
            switch (target) {
                case 'article':
                    mainContent.innerHTML =
                        '<h2>文章管理</h2>' +
                        '<button class="btn" onclick="addArticle()">添加文章</button><br>' +
                        '<button class="btn" onclick="deleteArticle()">删除文章</button>';
                    break;
                case "styles":
                    mainContent.innerHTML =
                        '<h2>样式管理</h2>' +
                        '<button class="btn" onclick="addStyle()">导入样式</button><br>';
                    break; // 确保这里有一个 break 语句
                default:
                    mainContent.innerHTML = '<p>欢迎 {{ panel_username }} 使用博客后台管理面板</p>';
            }
        }

        function addArticle() {
          window.location.href = "add_article"
        }

        function deleteArticle() {
            window.location.href = "delete_article"
            // 这里可以添加删除文章的具体逻辑
        }

        function addStyle() {
            window.location.href = "import_style";
        }
    </script>
</body>
</html>
